package com.ruoyi.statisticalCenter.controller;

import java.util.List;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.statisticalCenter.domain.vo.ScContractAreaRemittanceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.statisticalCenter.domain.ScContractAreaRemittance;
import com.ruoyi.statisticalCenter.service.IScContractAreaRemittanceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 承包区汇款Controller
 *
 * @author pyx
 * @date 2024-03-01
 */
@RestController
@Api(tags = "统计中心-承包区汇款汇总")
@RequestMapping("/sc/remittance")
public class ScContractAreaRemittanceController extends BaseController
{
    @Autowired
    private IScContractAreaRemittanceService scContractAreaRemittanceService;

    /**
     * 查询承包区汇款列表
     */
    @PostMapping("/list")
    @ApiOperation("查询承包区汇款列表")
    public R list(@RequestBody ScContractAreaRemittanceVo scContractAreaRemittanceVo)
    {
        List<ScContractAreaRemittance> list = scContractAreaRemittanceService.selectScContractAreaRemittanceList(scContractAreaRemittanceVo);
        if (list == null || list.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(list));
        }
    }


    @ApiOperation("cache")
    @GetMapping("cache/{time}")
    public R cache(@PathVariable String time) {
        return scContractAreaRemittanceService.cache(time);
    }

    /**
     * 新增承包区汇款
     */
    @PostMapping("/add")
    @ApiOperation("新增承包区汇款")
    public R addSave(@RequestBody ScContractAreaRemittance scContractAreaRemittance)
    {
        return scContractAreaRemittanceService.insertScContractAreaRemittance(scContractAreaRemittance);
    }

    /**
     * 修改承包区汇款
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ScContractAreaRemittance scContractAreaRemittance)
    {
        return toAjax(scContractAreaRemittanceService.updateScContractAreaRemittance(scContractAreaRemittance));
    }

    /**
     * 删除承包区汇款
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(scContractAreaRemittanceService.deleteScContractAreaRemittanceByIds(ids));
    }
}
